/*
 * ========THE SOLMIX PROJECT=====================================
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * http://www.gnu.org/licenses/ 
 * or see the FSF site: http://www.fsf.org. 
 */

package org.solmix.services.rpc;

import java.util.List;

import org.solmix.services.data.RPCManagerData;
import org.solmix.services.datasource.DSRequest;
import org.solmix.services.datasource.DSResponse;
import org.solmix.services.exception.SLXException;
import org.solmix.services.types.TransactionPolicy;

/**
 * @author solomon
 * @since 0.0.1
 * @version $ID$ 2011-1-1 solmix-api
 */
public interface RPCManager
{

   void setContext( RPCManagerData data );

   int requestCount();

   RPCManagerData getContext();

   void send( DSRequest dsRequest, DSResponse dsResponse ) throws SLXException;

   void send( DSRequest dsRequest, Object data ) throws SLXException;

   void send( Object data ) throws SLXException;

   void send( RPCRequest rpcRequest, Object data ) throws SLXException;

   void send( RPCRequest rpcRequest, RPCResponse rpcResponse ) throws SLXException;

   void send( RPCResponse rpcResponse ) throws SLXException;

   void sendFailure( Object request, String error ) throws SLXException;

   void sendFailure( Object request, Throwable t ) throws SLXException;

   void sendSuccess( RPCRequest rpcRequest ) throws SLXException;

   void sendXMLString( DSRequest dsRequest, String xml ) throws SLXException;

   void sendXMLString( RPCRequest rpcRequest, String xml ) throws SLXException;

   void registerCallback( RPCManagerCompletionCallback callback );

   RPCRequest getRequest();

   List< RequestType > getRequests();

   DSResponse getResponse( DSRequest req );

   RPCResponse getResponse( RPCRequest req );

   void freeDataSources() throws SLXException;

   void applyEarlierResponseValues( DSRequest dsReq ) throws SLXException;

   Object getRequestContext();

   void setRequestContext( Object context ) throws SLXException;

   /**
    * @return
    * @throws SLXException
    */
   boolean requestQueueIncludesUpdates() throws SLXException;

   /**
    * @param transactionPolicy
    * @throws SLXException
    */
   void setTransactionPolicy( TransactionPolicy transactionPolicy ) throws SLXException;

   /**
    * @return
    */
   Boolean getRequestProcessingStarted();

   /**
    * @param requestProcessingStarted
    */
   void setRequestProcessingStarted( Boolean requestProcessingStarted );

   /**
    * @return
    */
   Long getTransactionNum();

   /**
    * @param transactionNum
    */
   void setTransactionNum( Long transactionNum );

   /**
    * @return
    */
   TransactionPolicy getTransactionPolicy();
}
